package cn.mw.cmdb.enums;

public enum MonitorModeType {
    SNMP(1, "SNMP","161",2,2)
    , SNMPv1(2, "SNMPv1","161",2,2)
    , SNMPv2(3, "SNMPv2","161",2,2)
    , SNMPv3(4, "SNMPv3", "161",2,2)
    , Agent(5,"Agent", "10050",1,1)
    , ICMP(6,"ICMP", "10050",4,1)
    , IPMI(7,"IPMI", "623",5,3)
    , Http(8,"Http","443",6,1)
    , VCenter(9,"VCenter", "443",7,1)
    , SSH(10,"SSH","10050",8,1)
    , MODBUS(11,"MODBUS","10050",9,1)
    , ODBC(12,"ODBC","10050",10,1)
    , JMX(13,"JMX","10049",11,4)
    , API(14,"API","443",12,1)
    , SCRIPT(15,"SCRIPT","10050",13,1)
    , NetWorkDevice(99,"NetWorkDevice","99999",99,99);
    private int code;
    //监控名称
    private String name;
    //默认监控端口
    private String port;
    //监控方式
    private int monitorMode;
    //对应zabbix接口类型
    private int interfaceType;

    MonitorModeType(int code, String name, String port, int monitorMode, int interfaceType){
        this.code = code;
        this.name = name;
        this.port = port;
        this.monitorMode = monitorMode;
        this.interfaceType = interfaceType;
    }

    public String getPort(){
        return this.port;
    }

    public String getName() { return this.name; }

    public int geInterfaceType() { return this.interfaceType; }

    public int getMonitorMode(){ return this.monitorMode; }

    public static MonitorModeType getInfoByMonitorMode(int monitorMode) {
        for(MonitorModeType r : MonitorModeType.values()) {
            if(r.getMonitorMode() == monitorMode) {
                return r;
            }
        }
        return null;
    }

    public static String getMonitorName(int monitorMode) {
        for(MonitorModeType r : MonitorModeType.values()) {
            if(r.getMonitorMode() == monitorMode) {
                return r.getName();
            }
        }
        return null;
    }

    public static Integer getMonitorModel(String name) {
        for(MonitorModeType r : MonitorModeType.values()) {
            if(r.getName().equals(name)) {
                return r.getMonitorMode();
            }
        }
        return null;
    }

    public static MonitorModeType getInfoByName(String name) {
        for(MonitorModeType r : MonitorModeType.values()) {
            if(r.getName().equals(name)) {
                return r;
            }
        }
        return null;
    }
}
